<?php

namespace app\admin\model;

use think\facade\Filesystem;
use think\model\concern\SoftDelete;

class Plugin extends AdminModel
{
    use SoftDelete;

    protected $name = 'system_plugin';
    protected $autoWriteTimestamp = true;
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';
    protected $defaultSoftDelete = null;

    /**
     * 新增、更新需要操作的字段
     */
    protected $submitField = [
    ];

    protected $schema = [
        'id'          => 'int' ,
        'name'        => 'string' , //插件名
        'flag'        => 'string' ,//插件标识
        'description' => 'string' ,//插件描述
        'icon'        => 'string' ,//插件图标
        'is_admin'    => 'int' ,//是否有后台管理
        'identifier'  => 'string' ,//插件唯一标识
        'author'      => 'string' ,
        'status'      => 'int' ,//是否停用
        'createtime'  => 'int' ,
        'updatetime'  => 'int' ,
        'deletetime'  => 'int' ,
        'is_install'  => 'int' ,
        'is_config'   => 'int' ,
        'is_menu'     => 'string'
    ];


    public function getIconAttr ( $value , $data )
    {
        return Filesystem::getDiskConfig('plugins' , 'url') . '/plugins/' . $data['flag'] . '/' . $value;
    }
}

